<!-- 头部开始 -->
<div class="header">
<!--    <div class="header_r"><img src="img/tx.jpg" width="30"></div>-->
    <div class="header_l"><a href="javascript:history.back(-1)"></a></div>
    <div class="header_m">我的银行卡</div>
</div>
<!-- 头部结束 -->

<!--店铺基本信息开始-->
<?php if($cardlist){foreach($cardlist AS $val){?>
<div class="address">
    <p class="address-xm"><?=$val['bank_uname']?>　　　<?=substr($val['bank_card'],0,4).'********'.substr($val['bank_card'],-4)?></p>
    <p class="address-dz"><?=$val['bank']?> <?=$val['bank_name']?></p>
    <div class="add-mo"><span><a href="javascript:void(0)" bank_uname="<?=$val['bank_uname']?>" bank_card="<?=$val['bank_card']?>" bank="<?=$val['bank']?>" bank_name="<?=$val['bank_name']?>" vid="<?=$val['bank_id']?>"  class="add-mo-bj cd-popup-trigger2 putedit">编辑</a><a href="javascript:void(0)" bid="<?=$val['bank_id']?>" class="add-mo-sc putDelete">删除</a></span><label style="display:inline"><input type="radio" class="setDefault" value="<?=$val['cust_id'].'_'.$val['bank_id']?>" <?=$val['is_default'] == '1' ? 'checked="checked"' : ''?>>默认银行卡</label></div>
</div>
<?php }}?>
    
<div class="add cd-popup-trigger2 putAdd">+ 新增卡号</div>
<!--店铺基本信息结束-->
    
<!--新增地址开始-->
<div class="cd-popup2" role="alert">
    <div class="cd-popup-container2">
        <div id="PopupLayer2" class="PopupLayer2"><a class="close cd-popup-close2"></a>
            <p class="xd-dz">新增银行卡</p>
            <div class="xd-xzdz2"><span>开户姓名：</span><input type="text" name="bank_uname" class="checkval" itv="开户姓名" placeholder="提现账户开户人姓名"></div>
            <div class="xd-xzdz2"><span>选择银行：</span>
                <div class="ldcs">
                    <select name="bank" itv="选择提现银行" class="checkval">
                        <option value="">请选择提现银行</option>
                        <?php $banks = getSysconfig('cashBank');if($banks){foreach(explode(',',$banks) AS $vv){?>
                        	<option value="<?=$vv?>"><?=$vv?></option>
                        <?php }}?>
                    </select>  
                </div>
            </div>
            <input type="hidden" value="" id="thisval" />
            <div class="xd-xzdz2"><span>支行名称：</span><input type="text" name="bank_name" itv="支行名称" class="" placeholder="开户支行名称，支付宝可不填"></div>
            <div class="xd-xzdz2"><span>银行卡号：</span><input type="text" name="bank_card" itv="银行卡号" class="checkval" placeholder="提现银行卡号"></div>
            <p class="canshu_n"><a href="javascript:void(0)" id="putSubmit">确定</a></p>
        </div>
    </div>
</div>
<!--新增地址结束-->

<!--<div class="fiex nav"> <a class="icon-shouye fiex_on" href="/index/index/sek/<?=$sek?>"><br />-->
  <!--首页</a> <a class="icon-fenlei" href="/cate/main/sek/<?=$sek?>"><br />-->
  <!--分类</a> <a class="icon-gouwu" href="/cart/index/sek/<?=$sek?>"><br />-->
  <!--购物车</a> <a class="icon-geren" href="/saler/index/sek/<?=$sek?>"><br />-->
  <!--用户中心</a> </div>-->
<div class="fiex nav">
	<a class="icon-shouye" style="width:50%" href="/index/index/sek/<?=mySpreadSek(session('loginUid'))?>"><br />
		我的店铺</a> <a style="width:50%" class="icon-geren fiex_on" href="/saler/index/sek/<?=mySpreadSek(session('loginUid'))?>"><br />
	用户中心</a> </div>

<script src="/statics/js/layer.js"></script>
<script>
$(function(){
	$('#putSubmit').click(function(){
		mreturn = 1;
		$('.checkval').each(function(){
			if(!$(this).val()){
				layer.msg($(this).attr('itv')+'不能为空！', {icon: 0});
				mreturn = 0;return false;
			}
		});
		if(mreturn){
			$.post('/saler/editCart',{'id':$('#thisval').val(),'dosubmit':'1','bank':$('select[name="bank"]').val(),'bank_name':$('input[name="bank_name"]').val(),'bank_uname':$('input[name="bank_uname"]').val(),'bank_card':$('input[name="bank_card"]').val()},function(data){
				if(data.code == '1'){
					layer.msg(data.msg, {icon: 1});
					setTimeout(function(){location.reload();},1000);
				}else{
					layer.msg(data.msg, {icon: 0});
				}
			},'json');
		}
	});
	$('.setDefault').click(function(){
		$.get('/saler/setDefault',{'data':$(this).val()},function(data){
			if(data.code == '1'){
				layer.msg(data.msg, {icon: 1});
				setTimeout(function(){location.reload();},1000);
			}else{
				layer.msg(data.msg, {icon: 0});
			}
		},'json');
	});
	$('.putedit').click(function(){
		$('select[name="bank"]').val($(this).attr('bank'));
		$('input[name="bank_name"]').val($(this).attr('bank_name'));
		$('input[name="bank_uname"]').val($(this).attr('bank_uname'));
		$('input[name="bank_card"]').val($(this).attr('bank_card'));
		$('#thisval').val($(this).attr('vid'));
	});
	$('.putAdd').click(function(){
		$('select[name="bank"]').val('');
		$('input[name="bank_name"]').val('');
		$('input[name="bank_uname"]').val('');
		$('input[name="bank_card"]').val('');
		$('#thisval').val('');
	});
	$('.putDelete').click(function(){
		_this = $(this);
		layer.confirm('确认删除该银行卡吗 ?', { btn: ['确认','取消']},       
               function(){
					$.get('/saler/drop',{'id':_this.attr('bid')},function(data){
						if(data.code == '1'){
							layer.msg('删除成功', {icon: 1});
							setTimeout(function(){location.reload();},1000);
						}else{
							layer.msg('操作失败', {icon: 0});
						}
					},'json');
   			   },    
               function(){});
		return false;
	});
})
</script>